table.INDEX_CREATE_BEGIN Function

Syntax

V Index_Create_Begin(C Tagname,C Order_expression[,C Filter_expression[,C Index_Type]])

Arguments

Tagname

Any character string, up to 32 characters long, used to identify the index. Spaces are not permitted in the tag name.

Order_expression

A character expression indicating the field or combination of fields used to order the index.

Filter_expression

Optional. Default = all records. A character filter expression that selects the records to be indexed.

Index_Type

Optional. A string of character flags that can specify a descending sort order (?D'), or include only records with unique key values (?U'). By default, an index is ascending and includes duplicate key values.

Description

Begin creation of a new index, add the first tag.

Discussion

The .INDEX_CREATE_BEGIN() method starts the definition of a new index file for a table. Use this method when you want to recreate the entire index file from scratch. If you want to add indexes to an existing production index file, use the <TBL>.INDEX_TAG_ADD() method. An index file must contain at least one index tag. The first index tag is defined through .INDEX_CREATE_BEGIN(); subsequent index tags are defined by the .INDEX_ADD() method. The index file definition is completed and the file is created by the <TBL>.INDEX_CREATE_END() method. If the filename given to this index file matches the table name, or if the filename is omitted, the index file becomes the production index file that is opened automatically with the table. Note : There are higher level functions that may be easier to use. See GET_INDEX_DEFINITIONS(), INDEXES_MATCH_DEFSTRING(), and CREATE_INDEXES().

Example

Create a new production index file with a first name and a last name index tag.

tbl = table.current()
tbl.index_create_begin("LASTNAME", "LAST_NAME")
tbl.index_add("FIRSTNAME", "FIRST_NAME")
index1 = tbl.index_create_end()

Create a new temporary index file, but explicitly name the index file so that it is not the production index. Filter the index for state = CA, and include unique keys only.

tbl = table.current()
tbl.index_create_begin("CA customers", "LAST_NAME", "State_prov = 'CA'", "U")
index2 = tbl.index_create_end(a5.get_path()+ chr(92) + "temp.cdx")

See Also